<?php
/**
 * FlickrPhotosets class file
 * @package FlickrPhotosets
 */

/**
 * This is the base class of all classes in the FlickrPhotosets package.
 * 
 * It provides any functions that are common among child classes. This class handles
 * the basic functions of the app, including connecting to the database, creating
 * the Facebook object, and creating the Flickr object.
 * 
 * @package FlickrPhotosets
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @version 8.5.28
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */
abstract class FlickrPhotosets {
	
	/**
	 * The name of the application.
	 * @var string
	 */
	public $application_name;
	
	/**
	 * The call url.
	 * @var string
	 */
	public $callback_url;
	
	/**
	 * The canvas url.
	 * @var string
	 */
	public $canvas_url;
	
	/**
	 * The user's Flickr Photosets configuration
	 * @var array
	 */
	public $config = array();
	
	/**
	 * The database object
	 * @var FP_Database
	 */
	protected $_db;
	
	/**
	 * Debug mode
	 * @var boolean
	 */
	public $debug = false;
	
	/**
	 * The Facebook object
	 * @var Facebook
	 */
	public $facebook;
	
	/**
	 * The Flickr object
	 * @var phpFlickr
	 */
	public $flickr;
	
	/**
	 * The user's Flickr information
	 * @var array
	 */
	public $flickr_user;
	
	/**
	 * The application logger
	 * @var FP_Logger
	 */
	public $log;
	
	/**
	 * The Flickr ID
	 * @var string
	 */
	public $nsid;
	
	/**
	 * The current page
	 * @var int
	 */
	public $page;
	
	/**
	 * The user's Facebook ID
	 * @var string
	 */
	public $uid;
	
	/**
	 * The viewing user's Facebook ID
	 * @var string
	 */
	public $viewer_uid;
	
	/**
	 * The hashing method to use
	 */
	const hash_method = 'sha512';
	
	/**
	 * Creates the Facebook object and connects to the database.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 */
	public function __construct() {
		if (APP_DOWN) {
			die('<fb:error><fb:message><fb:application-name /> is currently down for maintenance.</fb:message>We hope to be back soon.</fb:error>');
		}
		
		// Set up the Facebook client
		$this->facebook = new Facebook(FACEBOOK_API_KEY, FACEBOOK_API_SECRET);
		$this->viewer_uid = $this->facebook->user;
		
		// Get properties from Facebook
		try {
			$this->get_app_properties();
		} catch (FacebookRestClientException $e) {
			$this->uid = $this->facebook->require_login();
			$this->get_app_properties();
		}
		
		// Initiate the connection to the database
		$this->connect_db();
		
		// Create the logger
		$this->log = new FP_Logger($this->_db);
		
		// Set debug mode
		if (isset($_GET['debug']) and $this->viewer_uid = '1470030056') {
			$this->debug = true;
		}
	}
	
	/**
	 * Fixes the issue with the Flickr API key.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 */
	protected function _migrate_flickr_key() {
		if ($this->config['flickr_token']) {
			$temp_flickr = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET);
			$temp_flickr->setToken($this->config['flickr_token']);
			$check_auth = $temp_flickr->auth_checkToken();
			if (empty($check_auth)) {
				die('<fb:if-is-user uid="'.$this->uid.'"><fb:error><fb:message>Your Flickr Account</fb:message>We had a little problem with <fb:application-name />, so you\'ll need to re-authorize Flickr for the app to continue working. <a href="'.$this->callback_url.'/auth.php?uid='.$this->uid.'">Click here to re-authorize.</a></fb:error><fb:else><fb:error><fb:message><fb:name uid="'.$this->uid.'" possessive="true" firstnameonly="true" /> Flickr Account</fb:message>We had a little problem with <fb:application-name />, so <fb:name uid="'.$this->uid.'" firstnameonly="true" /> will need to reauthorize <fb:pronoun uid="'.$this->uid.'" possessive="true" /> Flickr account before we can show you <fb:pronoun uid="'.$this->uid.'" possessive="true" /> photos.</a></fb:error></fb:else></fb:if-is-user>');
			}
		}
	}
	
	/**
	 * Initiates the connection to the database.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return boolean True if connected
	 */
	final protected function connect_db() {
		if (DB_TYPE == 'data_store') {
			$this->_db = new FlickrPhotosetsDataStore();
		}
		else {
			$this->_db = new FlickrPhotosetsMysqlDB(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_TABLE);
		}
	}
	
	/**
	 * Echoes a statement, but only in debug mode.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string The strings to echo
	 */
	final public function echo_debug() {
		if ($this->debug) {
			$error = '';
			$args = func_get_args();
			foreach ($args as $arg) {
				$error .= $arg;
			}
			trigger_error($error);
		}
	}
	
	/**
	 * Print or echo an error message using FBML.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param array $error An array with the error parameters
	 * @param boolean $return Whether or not to return the error string
	 * @return string The error string (if $echo param set to false)
	 */
	public function error($error, $return = false) {
		// Replace some things if the user is the viewer
		if ($this->uid == $this->viewer_uid) {
			
			// If there is a separate message or title
			$error['title'] = (isset($error['title_you'])) ? $error['title_you'] : $error['title'];
			$error['message'] = (isset($error['message_you'])) ? $error['message_you'] : $error['message'];
			
			// Find some verbs and replace them if the owner is the viewer
			$error['title'] = str_replace('has', 'have', $error['title']);
			$error['message'] = str_replace('has', 'have', $error['message']);
			
			// Replace strings inside #s
			$error['title'] = preg_replace('/#([A-Za-z0-9]+)#([A-Za-z0-9]+)#/', '$2', $error['title']);
			$error['message'] = preg_replace('/#([A-Za-z0-9]+)#([A-Za-z0-9]+)#/', '$2', $error['message']);
			
		}
		else {
			$error['title'] = preg_replace('/#([A-Za-z0-9]+)#([A-Za-z0-9]+)#/', '$1', $error['title']);
			$error['message'] = preg_replace('/#([A-Za-z0-9]+)#([A-Za-z0-9]+)#/', '$1', $error['message']);
		}
		
		// Replace %uid% with the uid
		$error['title'] = str_replace("%uid%", $this->uid, $error['title']);
		$error['message'] = str_replace("%uid%", $this->uid, $error['message']);
		
		// Print the header
		$error_string = '';
		if ($error['with_header']) {
			$error_string .= '<fb:header decoration="add_border">'.$this->application_name.'</fb:header>';
		}
		
		// Print the error
		$error_string .= '<fb:error><fb:message>'.$error['title'].'</fb:message>'.$error['message'].'</fb:error>';
		
		// Echo or return
		if ($return) {
			return $error_string;
		}
		else {
			echo $error_string;
		}
		
		// Die if the error is fatal
		if ($error['fatal']) {
			die();
		}
	}
	
	/**
	 * Gets the google-analytics FBML tag.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $page The optional page name
	 * @return string The analytics tag
	 */
	final public function get_analytics($page = '') {
		if (GOOGLE_ANALYTICS_ACCOUNT !== '') {
			$analytics = '<fb:google-analytics uacct="'.GOOGLE_ANALYTICS_ACCOUNT.'"';
			$analytics .= (empty($page)) ? '' : ' page="'.$page.'"';
			$analytics .= ' />';
			return $analytics;
		}
		return '';
	}
	
	/**
	 * Gets a comma-separated list of the app's developers.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return string List of developers
	 */
	public function get_app_developers($get_all = true) {
		if ($this->app_properties) {
			
			if ($get_all) {
				$developer_uids = array();
				foreach ($this->app_properties['developers'] as $dev) {
					$developer_uids[] = $dev['uid'];
				}
				return join($developer_uids, ',');
			}
			else {
				return $this->app_properties['developers'][0]['uid'];
			}
			
		}
		return false;
	}
	
	/**
	 * Gets the application properties from Facebook.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return boolean Whether the call was successful
	 */
	protected function get_app_properties() {
		if ($this->facebook) {
			
			// Query Facebook for the information
			$properties = $this->facebook->api_client->call_method(
				'application.getPublicInfo',
				array('application_api_key' => FACEBOOK_API_KEY)
			);
			$app_props = $this->facebook->api_client->admin_getAppProperties(
				array('callback_url')
			);
			$properties['callback_url'] = substr($app_props['callback_url'], 0, -1);
			
			// Assign variables
			$this->application_name = $properties['display_name'];
			$this->callback_url = $properties['callback_url'];
			$this->canvas_url = 'http://apps.new.facebook.com/'.$properties['canvas_name'];
			$this->app_properties = $properties;
			
			return true;
		}
		return false;
	}
	
	/**
	 * Gets the user's configuration data.
	 * 
	 * This function uses the $uid attribute to determine which user's
	 * configuration information to get.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $uid The UID of the user (otherwise used the UID attribute)
	 * @return boolean True if data was retrieved successfully
	 */
	final public function get_info($uid = '') {
		// If the UID param is empty, use the attribute
		if (empty($uid)) {
			$uid = $this->uid;
		}
		
		// What is returned from get_info is the config array
		$this->config = $this->_db->get_info($uid);
		return ($this->config === false) ? false : true;
	}
	
	/**
	 * Get the time of the last profile update.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return int The time in PHP format
	 */
	public function get_last_profile_update() {
		$result = $this->_db->get_last_profile_update($this->uid);
		return strtotime($result['time']);
	}
	
	/**
	 * Returns the fb:name tag to show a user's name. Respects the
	 * user's name privacy setting.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param boolean $use_my Whether or not to replace the name with My
	 * @param boolean $possessive Use the possessive form of the name
	 * @return string The FBML to show the name
	 */
	public function get_name_fbml($use_my = false, $possessive = true, $use_you = true) {
		$name = '<fb:name uid="'.$this->uid.'" linked="no" capitalize="true"';
		$name .= ($possessive) ? ' possessive="true"' : ' possessive="false"';
		$name .= ($use_you) ? ' useyou="true"' : ' useyou="false"';
		if ($this->config['privacy_name'] == $this->privacy_name['first']) {
			$name .= ' firstnameonly="true"';
		}
		$name .= ' />';
		if ($use_my) {
			$name = '<fb:if-is-user uid="'.$this->uid.'">My<fb:else>'.$name.'</fb:else></fb:if-is-user>';
		}
		return $name;
	}
	
	/**
	 * Gets the page number from the URL.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 */
	public function get_page() {
		$page = $_REQUEST['p'];
		$this->page = ($page < 1) ? 1 : $page;
	}
	
	/**
	 * Gets all of the photos where the user has tagged their friends.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return array The photos array
	 */
	public function get_tagged_photos() {
		return $this->flickr->photos_search(array(
			'privacy_filter' => $this->privacy_filter['public'],
			'per_page'       => $this->photos_per_page,
			'page'           => $this->page,
			'extras'         => 'date_upload',
			'machine_tags'   => 'fb:user=',
		));
	}
	
	/**
	 * Gets the tagged photos of a user.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The user ID
	 * @param boolean $all Get all of the photos (otherwise get the current page)
	 * @return array The photos array
	 */
	public function get_tagged_photos_of($uid, $uid2 = null, $all = false) {
		
		// Figure out how many photos per page
		$photos_per_page = ($all) ? 500 : $this->photos_per_page;
		
		// Two users
		if (isset($uid2)) {
			$photos = $this->flickr->photos_search(array(
				'privacy_filter'   => $this->privacy_filter['public'],
				'per_page'         => $photos_per_page,
				'page'             => $this->page,
				'extras'           => 'date_upload',
				'machine_tags'     => 'fb:user='.$uid.',fb:user='.$uid2,
				'machine_tag_mode' => 'all',
			));
		}
		// A single user
		else {
			$photos = $this->flickr->photos_search(array(
				'privacy_filter' => $this->privacy_filter['public'],
				'per_page'       => $photos_per_page,
				'page'           => $this->page,
				'extras'         => 'date_upload',
				'machine_tags'   => 'fb:user='.$uid,
			));
		}
		
		return $photos;
		
	}
	
	/**
	 * Get the UID from an NSID.
	 * 
	 * Use this function to lookup a Facebook user from their Flickr ID.
	 * Returns a string that contains the UID if the user was found.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $nsid The Flickr ID
	 * @return int The Facebook UID
	 */
	public function get_uid_from_nsid($nsid) {
		return $this->_db->get_uid_from_nsid($nsid);
	}
	
	/**
	 * Has the user enabled the gallery?
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return boolean Whether the user has the gallery enabled
	 */
	public function has_enabled_gallery() {
		if ($this->config['enable_gallery_photostream'] or $this->config['enable_gallery_photosets'] or $this->config['enable_gallery_geotagged']) {
			return true;
		}
		return false;
	}
	
	/**
	 * Initialize Flickr.
	 * 
	 * This will create the Flickr object. By default it will enable the
	 * cache and check for new photos and photosets. If a user wishes to
	 * display any level of private photos, the token will be set, which
	 * causes all calls to be authenticated.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param boolean $enable_cache Enable the cache by default
	 * @param boolean $echeck_for_auth Make sure user has Flickr information first
	 * @param boolean $check_for_new Enable the check for new photos and photosets
	 * @param boolean $disable_authentication Disable authentication of the Flickr object
	 */
	public function init_flickr($enable_cache = true, $check_for_auth = true, $check_for_new = true, $disable_authentication = false) {
		
		// Make sure Flickr is authorized first
		if ($check_for_auth and !$this->is_flickr_authorized()) {
			$this->error(FlickrPhotosetsErrors::$not_linked);
		}
		
		// Initialize the Flickr object
		$this->flickr = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET);

		// Enable the cache by default
		if ($enable_cache) {
			$this->flickr->enableCache('fs', $this->cache_dir);
		}

		// Set the token if the filter is anything other than public
		if (($this->config['privacy_filter'] != $this->privacy_filter['public']) and !$disable_authentication) {
			$this->flickr->setToken($this->config['flickr_token']);
			if (!FP_Auth::check_token($this->flickr)) {
				$this->facebook->redirect($this->callback_url.'/auth.php?uid='.$this->uid);
			}
		}

		// Get the user's Flickr info
		$this->nsid = $this->config['flickr_nsid'];
		$this->flickr_user = $this->flickr->people_getInfo($this->nsid);

		// Check for newly uploaded photos and photosets and log the results
		if ($check_for_new) {
			//$this->check_for_new_photos();
			//$this->check_for_new_photosets();
		}
		
	}
	
	/**
	 * Figures out whether the user has authorized their Flickr account.
	 * This will only work correctly if the user's configuration has been
	 * retrieved.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return boolean True if the user has authorized their Flickr account
	 */
	public function is_flickr_authorized() {
		return (empty($this->config['flickr_nsid']) or empty($this->config['flickr_token'])) ? false : true;
	}
	
	/**
	 * Remove photos from the array that do not match privacy settings.
	 * It will only evaluate the array if appropriate (the user has restricted
	 * which private photos they are showing).
	 *
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param array $photos The array of photos
	 * @return array The cleaned array
	 */
	final public function remove_photos($photos) {
		
		// Only do this if the setting is not public or private
		if (($this->config['privacy_filter'] == $this->privacy_filter['friends']) or ($this->config['privacy_filter'] == $this->privacy_filter['family']) or ($this->config['privacy_filter'] == $this->privacy_filter['friends_family'])) {
						
			// Loop through the photos
			foreach ($photos as $key=>$photo) {
				
				// Get permissions
				if (isset($photo['visibility'])) {
					$perms = $photo['visibility'];
				}
				else {
					$perms = $this->flickr->photos_getPerms($photo['id']);
				}
				
				// If the photo is public, skip
				if ($perms['ispublic']) {
					continue;
				}
				
				// Always remove private
				if (!$perms['isfriend'] and !$perms['isfamily']) {
					unset($photos[$key]);
					continue;
				}
				
				// For friends: remove family only
				if ($this->config['privacy_filter'] == $this->privacy_filter['friends']) {
					
					if (!$perms['isfriend'] and $perms['isfamily']) {
						unset($photos[$key]);
					}
					
				} // For family: remove friends only
				else if ($this->config['privacy_filter'] == $this->privacy_filter['family']) {
					
					if ($perms['isfriend'] and !$perms['isfamily']) {
						unset($photos[$key]);
					}
					
				}

			}
			
		}
		
		// Return the array
		return $photos;
		
	}
	
	/**
	 * Require these variables to exist, otherwise redirect to homepage
	 * Will expand on this function to attempt to redirect to the "nearest" page
	 *  (for example: photoset page without sid will go to the photosets page)
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param $var The variable to require, followed my as many other vars as needed
	 */
	public function require_variables($var) {
		for ($i = 0, $args = func_num_args(); $i < $args; $i++) {
			$var = func_get_arg($i);
			if (empty($var)) {
				$this->facebook->redirect($this->canvas_url.'/index.php');
			}
		}
	}
	
	/**
	 * Saves the current configuration to the database ($config).
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @return boolean True if the query was successful
	 */
	public function save_config() {
		return $this->_db->save_config($this->config);
	}
	
	/**
	 * Inserts a user's Facebook ID and session key into the database.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The Facebook user id
	 * @param string $facebook_session_key The Facebook session key
	 * @return bool True if successfully added
	 */
	protected function set_facebook_info($facebook_uid, $facebook_session_key) {
		return $this->_db->set_facebook_info($facebook_uid, $facebook_session_key);
	}
	
	/**
	 * Sets the content of the profile info box.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 */
	public function set_info_box() {
		// Is the user pro?
		$pro = ($this->flickr_user['ispro']) ? ' (pro)' : '';
		
		// Get the user's groups
		$groups = $this->flickr->people_getPublicGroups($this->nsid);
		$group_items = array();
		$group_admin_items = array();
		foreach ($groups as $group) {
			if ($group['admin']) {
				$group_admin_items[] = array(
					'label' => $group['name'],
					'link' => 'http://www.flickr.com/groups/'.$group['nsid'].'/',
				);
			}
			else {
				$group_items[] = array(
					'label' => $group['name'],
					'link' => 'http://www.flickr.com/groups/'.$group['nsid'].'/',
				);
			}
		}
		
		// Set the info box
		$info_fields = array(
			array(
				'field' => 'Account',
				'items' => array(
					array(
						'label' => $this->flickr_user['username'].$pro,
						'link' => $this->flickr_user['profileurl'],
						'image' => 'http://flickr.com/buddyicons/'.$this->nsid.'.jpg',
					),
				),
			),
			array(
				'field' => 'Member Since',
				'items' => array(
					array(
						'label' => date("F j, Y", $this->flickr_user['photos']['firstdate']),
					),
				),
			),
			array(
				'field' => 'Photos',
				'items' => array(
					array(
						'label' => $this->flickr_user['photos']['count'],
						'link' => $this->flickr_user['photosurl'],
					),
				),
			),
			array(
				'field' => 'Groups',
				'items' => $group_items,
			),
		);
		$this->facebook->api_client->profile_setInfo('Flickr', 1, $info_fields, $this->uid);
	}
	
	/**
	 * Sets the ID of the last photo in the database.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $id The photo id
	 * @return boolean True if the query was successful
	 */
	private function set_last_photo($pid) {
		return $this->_db->set_last_photo($this->uid, $pid);
	}
	
	/**
	 * Saves a comma separated list of the user's sets in the database.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $photosets A comma separated list of the set ids
	 * @return boolean True if the query was successful
	 */
	protected function set_photosets($photosets) {
		return $this->_db->set_photosets($this->uid, $photosets);
	}
	
	/**
	 * Sets the user's profile FBML to the default.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param boolean $ref Whether or not to use fb:ref or just set the fbml
	 */
	public function set_profile_fbml($ref = false) {
		
		$url = $this->callback_url.'/profile.php?handle='.$this->uid;
		
		// If we are going to use a ref url
		if ($ref) {
			$profile = '<fb:ref url="'.$url.'" />';
		}
		// Otherwise, fetch the output from profile.php
		else {
			$curl = curl_init($url);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			$profile = curl_exec($curl);
			curl_close($curl);
		}
		
		$profile_main = str_replace('/update/?fromprofile', '/update/?fromprofilemain', $profile);
		
		// The profile action
		$profile_action = '<fb:profile-action url="'.$this->canvas_url.'/photos/of/">View Flickr Photos of <fb:name uid="profileowner" firstnameonly="true" reflexive="true" capitalize="true" /></fb:profile-action>';
		
		// Set the fbml
		$this->facebook->set_user($this->uid, $this->config['session_key']);
		$this->facebook->api_client->profile_setFBML('', $this->uid, $profile, $profile_action, '', $profile_main);
		
		return $true;
		
	}
	
	/**
	 * Updates the user's session key in the database
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The UID
	 * @param string $session_key The current session key
	 */
	private function update_session_key($uid, $session_key) {
		if ($session_key != $facebook->fb_params['session_key']) {
			return $this->_db->set_facebook_info($uid, $facebook->fb_params['session_key']);
		}
		return false;
	}
	
	/*****************************************************************
	
	The following variables are basically constants. PHP does not
	allow for constants that are arrays, so for consistency, anything
	that should be a constant is actually a variable.
	
	*****************************************************************/
		
	/**
	 * The directory for the phpFlickr cache.
	 * @var string
	 */
	public $cache_dir = CACHE_DIR;
	
	/**
	 * Standard Facebook colors.
	 * @var array
	 */
	public $fb_colors = array(
		'background' => '#f7f7f7',
		'grey'       => '#d8dfea',
	);
	
	/**
	 * Widths of Facebook things.
	 * @var array
	 */
	public $fb_sizes = array(
		'canvas'         => '760px',
		'profile_narrow' => '180px',
		'profile_wide'   => '380px',
	);
	
	/**
	 * The abbreviations used in the log.
	 * @var array
	 */
	public $log_info = array(
		'authorize' => 'installation of the app',
		'photo_story' => 'new photo notification',
		'set_story' => 'new set notification',
		'remove' => 'removal of the app',
		'tag_add' => 'addition of a tag',
		'tag_remove' => 'removal of a tag',
		'profile_update' => 'profile update',
	);
	
	/**
	 * The number of photos to display per page.
	 * @var int
	 */
	public $photos_per_page = 20;
	
	/**
	 * The number of photos to display per row on each page.
	 * @var int
	 */
	public $photos_per_row = 4;
	
	/**
	 * The number of photos to display on the profile by default.
	 * @var int
	 */
	public $profile_count = 5;

	/**
	 * The display types for the profile box.
	 * @var array
	 */
	public $profile_display = array(
		'last'        => 0,
		'recent'      => 1,
		'random'      => 2,
		'sets'        => 3,
		'overview'    => 4,
		'random_sets' => 5,
	);
	
	/**
	 * The modes for tag filtering on the profile.
	 * @var array
	 */
	public $profile_tagmode = array(
		'any' => 0,
		'all' => 1,
	);
	
	/**
	 * The sort methods for the profile box
	 * @var array
	 */
	public $profile_sort = array(
		'date_posted_desc' => 0,
		'date_posted_asc'  => 1,
		'date_taken_desc'  => 2,
		'date_taken_asc'   => 3,
		'interesting_desc' => 4,
		'interesting_asc'  => 5,
	);
	
	/**
	 * The privacy filter options. Correspond to the values
	 * used by Flickr.
	 * @var array
	 */
	public $privacy_filter = array(
		'public'         => 1,
		'friends'        => 2,
		'family'         => 3,
		'friends_family' => 4,
		'private'        => 5,
	);
	
	/**
	 * The Facebook visibility values.
	 * @var array
	 */
	public $privacy_visibility = array(
		'all'         => 0,
		'friends'     => 1,
		'non-limited' => 2,
	);
	
	/**
	 * The name privacy values.
	 * @var array
	 */
	public $privacy_name = array(
		'full' => 0,
		'first'  => 1,
	);
	
	/**
	 * The number of sets to display per page.
	 * @var int
	 */
	public $sets_per_page = 6;
	
}

?>